<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
    <title>Document</title>
    <style>
    .box{
        width: 200px;
        height: 200px;
        background: #ccc;
    }
    </style>
    <script type="text/babel">
        class ShowHide extends React.Component{
            constructor(...args){
                super(...args);

                this.state = {
                    display: 'block',
                    value:''
                };
            }

            fn(){
                this.setState({
                    display:this.state.display == 'block' ? 'none' : 'block'
                });
            }

            fn1(ev){
                this.setState({
                    value:ev.target.value
                }); 
            }

            render(){
                return <div>
                    <input type="button" value="显示隐藏" onClick={this.fn.bind(this)} />
                    <input onClick={this.fn1.bind(this)} onChange={this.fn1.bind(this)}/>
                    <span>{this.state.value}</span>
                    <div className="box" style={{
                        display:this.state.display
                    }}></div>
                </div>
            }
        }

       
        
        window.onload = function () {
            var  oDiv = document.getElementById('root');

            ReactDOM.render(
                <ShowHide/>,
                oDiv
            );
        }
    </script>
</head>
<body>
    <div id="root"></div>
</body>
</html>